package main

import (
	"context"
	"fmt"
	"google.golang.org/grpc"
	"google.golang.org/grpc/credentials/insecure"
	"kuangstudy-mall/srvs/order-srv/proto"
)

var orderClient proto.OrderClient

func InitClient() {
	conn, err := grpc.Dial("127.0.0.1:9500", grpc.WithTransportCredentials(insecure.NewCredentials()))
	if err != nil {
		panic(err)
	}
	orderClient = proto.NewOrderClient(conn)
}

func CreateOrder() {
	request := proto.OrderRequest{UserId: 1, Username: "feige", Address: "广州", Mobile: "155887878", Post: "412511"}
	order, err := orderClient.CreateGoodsOrder(context.Background(), &request)
	if err != nil {
		panic(err)
	}
	fmt.Println(order)
}

func main() {
	InitClient()
	CreateOrder()
}
